/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vehicle.bol;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import vehicle.dal.DAL;
import vehicle.entity.Abums;
import vehicle.entity.Customer;
import vehicle.entity.Vehicles;

/**
 *
 * @author lab1
 */
public class CarBOL {

    public List<Vehicles> showAllVehicle() {
        DAL dal = new DAL();
        List<Vehicles> listVe = new ArrayList<Vehicles>();
        try {
            ResultSet rs = dal.executeQuery("showAllVehicle", new ArrayList());
            while (rs.next()) {
                Vehicles ve = new Vehicles();
                ve.setVehicleID(rs.getInt("VehicleID"));
                ve.setVehilceName(rs.getString("VehicleName"));
                ve.setModulNumber(rs.getString("ModelNumber"));
                ve.setBrandID(rs.getInt("BrandID"));
                ve.setPrice(rs.getDouble("Price"));
                ve.setCylinder(rs.getString("Cylinder"));
                ve.setGearBox(rs.getString("GearBox"));
                ve.setSeries(rs.getString("Series"));
                ve.setCombustible(rs.getString("Combustible"));
                ve.setSeat(rs.getInt("Seat"));
                ve.setColor(rs.getString("Color"));
                ve.setQuantity(rs.getInt("Quantity"));
                ve.setImage(rs.getString("ImgUrl"));
                ve.setStatus(rs.getInt("STATUS"));
                listVe.add(ve);
            }
        } catch (Exception e) {
        } finally {
            dal.closeConnection();
        }
        return listVe;
    }

    public List<Vehicles> searchCarByVehicleName(String valueSearch) {
        DAL dal = new DAL();
        List<Vehicles> listVe = new ArrayList<Vehicles>();
        ArrayList a = new ArrayList();
        a.add(valueSearch);
        try {
            ResultSet rs = dal.executeQuery("searchCarByVehicleName", a);
            while (rs.next()) {
                Vehicles ve = new Vehicles();
                ve.setVehicleID(rs.getInt("VehicleID"));
                ve.setVehilceName(rs.getString("VehicleName"));
                ve.setModulNumber(rs.getString("ModelNumber"));
                ve.setBrandID(rs.getInt("BrandID"));
                ve.setPrice(rs.getDouble("Price"));
                ve.setCylinder(rs.getString("Cylinder"));
                ve.setGearBox(rs.getString("GearBox"));
                ve.setSeries(rs.getString("Series"));
                ve.setCombustible(rs.getString("Combustible"));
                ve.setSeat(rs.getInt("Seat"));
                ve.setColor(rs.getString("Color"));
                ve.setQuantity(rs.getInt("Quantity"));
                ve.setImage(rs.getString("ImgUrl"));
                ve.setStatus(rs.getInt("STATUS"));
                listVe.add(ve);
            }
        } catch (Exception e) {
        } finally {
            dal.closeConnection();
        }
        return listVe;
    }
    public List<Abums> showAbumByVehicleID(int vehicleID) {
        DAL dal = new DAL();
        List<Abums> listVe = new ArrayList<Abums>();
        ArrayList a = new ArrayList();
        a.add(vehicleID);
        try {
            ResultSet rs = dal.executeQuery("showAbumByVehicleID", a);
            while (rs.next()) {
                Abums ab = new Abums();
                ab.setImgUrl(rs.getString("ImgUrl"));
                listVe.add(ab);
            }
        } catch (Exception e) {
        } finally {
            dal.closeConnection();
        }
        return listVe;
    }
    public int OrderAndCustomer(Customer cus,int vehicleID)
    {

        return 0;
    }
}
